package com.jt.blog.controller;

import com.jt.blog.domain.Tag;
import com.jt.blog.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tang
 * @data 2021/10/13
 * @apiNode
 */
@RestController
@RequestMapping("/blog")
public class TagController {
    @Autowired
    private TagService tagService;

    private List<Tag> tags = new ArrayList<Tag>();
    @GetMapping("/get")
    public List<Tag> listTags(){
        if (tags.isEmpty()){
            tags.addAll(tagService.selectTags());
        }
        return tags;
    }
}
/*
   redis  分布式缓存
   Tomcat  本地缓存(JVM内部提供)
   Browser(查询)-->Nginx-->Gatewau，Gateway,...-->(Tomcat,Tomcat)
   查询-->本地cache-->分布式cache-->mysql
 */
